home *** CD-ROM | disk | FTP | other *** search
/ Aminet 39 / Aminet 39 (2000)(Schatztruhe)[!][Oct 2000].iso / Aminet / biz / swood / FW_AllInOne.lha / Makros / Suchen&Ersetzen < prev    next >
Text File  |  1998-01-18  |  13KB  |  527 lines

  1. /* Optimized with RexxOpt 1.7 */
  2.  
  3. Parse ARG FW
  4. if ~show('L',"rexxreqtools.library") then
  5. if ~addlib('rexxreqtools.library',0,-30,0) then;do
  6. 'ShowMessage 1 1 "Fehler...." "Benötige Libs:rexxreqtools.library" " A B B R U C H ! !" "Okay" "" ""'
  7. exit
  8. end
  9. IF ~show('L','tritonrexx.library') then
  10. IF ~ADDLIB('tritonrexx.library',10,-30,0) THEN;DO
  11. 'ShowMessage 2 1 "Fehler...." "Benötige Libs:tritonrexx.library" "" "Abbruch" "" ""'
  12. exit
  13. END
  14. R='0A'X
  15. SIGNAL ON syntax
  16. If open('Hilfe',"S:FW_Paket.prefs","R") then;do
  17. HilfeVerz=readln('Hilfe')
  18. Call Close('Hilfe')
  19. End
  20. else HilfeVerz=''
  21. If FW='' then;do
  22. Address='FinalW'
  23. Options results
  24. STATUS PORTNAME
  25. FW=result
  26. End
  27. Address(FW)
  28. FWP="FinalWriterPubScreen"
  29. lista.0=2
  30. lista.1='   Text   '
  31. lista.2='   Code   '
  32. liste.0=3
  33. liste.1='   ----   '
  34. liste.2='   Text   '
  35. liste.3='   Code   '
  36. listb.0=3
  37. listb.1=' ------------- '
  38. listb.2='  Schriftart'
  39. listb.3='Schriftschnitt'
  40. Wort='';dis=1;fo='';spez=0
  41. Texttool
  42. Status PARAPOS
  43. Parse Var result bzeile bspalte ezeile espalte
  44. if ezeile~='' then;do
  45. extract;Wort=result
  46. pos=lastpos(R,Wort)
  47. if pos~=0 then Wort=Left(Wort,pos)
  48. dis=0
  49. Status FontName
  50. fo=result
  51. spez=1
  52. end
  53. dir=''
  54. apptags='TRCA_Name     SuchenErsetzen',
  55. 'TRCA_LongName "Suchen und Ersetzen"',
  56. 'TRCA_Info     "für FinalWriter"',
  57. 'TRCA_Version  "2.1 registered"',
  58. 'TRCA_Release  "3"',
  59. 'TRCA_Date     "06.01.98"',
  60. 'TAG_END'
  61. windowtags=WindowID(1),
  62. WindowPosition('TRWP_CENTERDISPLAY'),
  63. PubScreenName(FWP),
  64. WindowTitle("Suchen & Ersetzen"),
  65. WindowFlags('TRWF_NOSIZEGADGET|TRWF_NOMINTEXTWIDTH'),
  66. BeginMenu('Projekt'),
  67. MenuItem('Q_Verlassen',104),
  68. BeginMenu('?'),
  69. MenuItem('?_Info',101),
  70. MenuItem('H_Hilfe',103),
  71. 'HorizGroupAC',
  72. 'SpaceS',
  73. 'VertGroupAC',
  74. 'SpaceS',
  75. NamedFrameBox('Suchen nach'),
  76. 'HorizGroupAC',
  77. 'SpaceS',
  78. 'VertGroupAC',
  79. 'SpaceS',
  80. TextID('A_rt',10),
  81. 'SpaceS',
  82. CycleGadget('lista',0,10) 'TRAT_Flags TRCY_RIGHTLABELS TRAT_Value 0',
  83. StringGadget(Wort,11),
  84. 'SpaceS',
  85. 'EndGroup',
  86. 'SpaceS',
  87. 'VertGroupAC',
  88. 'SpaceS',
  89. TextID('S_pezifikation',12),
  90. 'SpaceS',
  91. CycleGadget('listb',spez,12) 'TRAT_Flags TRCY_RIGHTLABELS',
  92. 'HorizGroupAC',
  93. GetEntryButton(13) TRAT_DISABLED dis,
  94. StringGadget(fo,14) TRAT_DISABLED dis,
  95. 'EndGroup',
  96. 'SpaceS',
  97. 'EndGroup',
  98. 'SpaceS',
  99. 'EndGroup',
  100. 'Space',
  101. NamedFrameBox('Ersetzen durch'),
  102. 'HorizGroupAC',
  103. 'SpaceS',
  104. 'VertGroupAC',
  105. 'SpaceS',
  106. TextID('Ar_t',20),
  107. 'SpaceS',
  108. CycleGadget('liste',0,20) 'TRAT_Flags TRCY_RIGHTLABELS TRAT_Value 0',
  109. StringGadget('',21) 'TRAT_DISABLED 1',
  110. 'SpaceS',
  111. 'EndGroup',
  112. 'SpaceS',
  113. 'VertGroupAC',
  114. 'SpaceS',
  115. TextID('Spe_zifikation',22),
  116. 'SpaceS',
  117. CycleGadget('listb',0,22) 'TRAT_Flags TRCY_RIGHTLABELS TRAT_Value 0',
  118. 'HorizGroupAC',
  119. GetEntryButton(23) 'TRAT_DISABLED 1',
  120. StringGadget('',24) 'TRAT_DISABLED 1',
  121. 'EndGroup',
  122. 'SpaceS',
  123. 'EndGroup',
  124. 'SpaceS',
  125. 'EndGroup',
  126. 'Space',
  127. 'HorizGroupEC',
  128. Button('_Suchen',1),
  129. 'SpaceS',
  130. Button('_Ersetzen',2) 'TRAT_DISABLED 1',
  131. 'SpaceS',
  132. Button('_Alle',3) 'TRAT_DISABLED 1',
  133. 'EndGroup',
  134. 'SpaceS',
  135. 'EndGroup',
  136. 'SpaceS',
  137. 'EndGroup',
  138. 'EndProject'
  139. app=TR_CREATEAPP('TRCA_Name SuchenErsetzen')
  140. IF app ~='00000000'x THEN;DO
  141. window1=TR_OPENPROJECT(app,windowtags)
  142. IF window1 ~='00000000'x THEN;DO
  143. ende=0
  144. DO WHILE ~ende
  145. CALL TR_WAIT(app,'')
  146. DO WHILE TR_HANDLEMSG(app,'event')
  147. IF event.trm_class='TRMS_NEWVALUE' THEN;DO
  148. SELECT
  149. WHEN event.trm_id=10 THEN;do
  150. what=event.trm_data+1
  151. such=TR_GETATTRIBUTE(window1,11,'TROB_String')
  152. if what=1 then;do
  153. void=SetClip("Cod1",such)
  154. Cod2=GetClip("Cod2")
  155. CALL TR_SETATTRIBUTE(window1,11,'TROB_String',Cod2)
  156. end
  157. if what=2 then;do
  158. void=SetClip("Cod2",such)
  159. Cod1=GetClip("Cod1")
  160. CALL TR_SETATTRIBUTE(window1,11,'TROB_String',Cod1)
  161. end
  162. if what=3 then CALL TR_SETATTRIBUTE(window1,21,'TROB_String','')
  163. End
  164. WHEN event.trm_id=12 THEN;do
  165. what=event.trm_data+1
  166. such=TR_GETATTRIBUTE(window1,14,'TROB_String')
  167. if what=1 then;do
  168. void=SetClip("Spez2",such)
  169. CALL TR_SETATTRIBUTE(window1,13,'TRAT_Disabled',1)
  170. CALL TR_SETATTRIBUTE(window1,14,'TROB_String','')
  171. CALL TR_SETATTRIBUTE(window1,14,'TRAT_Disabled',1)
  172. end
  173. if what=2 then;do
  174. Spez1=GetClip("Spez1")
  175. CALL TR_SETATTRIBUTE(window1,13,'TRAT_Disabled',0)
  176. CALL TR_SETATTRIBUTE(window1,14,'TROB_String',Spez1)
  177. CALL TR_SETATTRIBUTE(window1,14,'TRAT_Disabled',0)
  178. end
  179. if what=3 then;do
  180. void=SetClip("Spez1",such)
  181. Spez2=GetClip("Spez2")
  182. CALL TR_SETATTRIBUTE(window1,14,'TROB_String',Spez2)
  183. end
  184. End
  185. WHEN event.trm_id=20 THEN;do
  186. what=event.trm_data+1
  187. such=TR_GETATTRIBUTE(window1,21,'TROB_String')
  188. if what=1 then;do
  189. void=SetClip("Cod4",such)
  190. CALL TR_SETATTRIBUTE(window1,21,'TROB_String','')
  191. CALL TR_SETATTRIBUTE(window1,21,'TRAT_Disabled',1)
  192. CALL TR_SETATTRIBUTE(window1,2,'TRAT_Disabled',1)
  193. CALL TR_SETATTRIBUTE(window1,3,'TRAT_Disabled',1)
  194. end
  195. if what=2 then;do
  196. Cod3=GetClip("Cod3")
  197. CALL TR_SETATTRIBUTE(window1,21,'TROB_String',Cod3)
  198. CALL TR_SETATTRIBUTE(window1,21,'TRAT_Disabled',0)
  199. CALL TR_SETATTRIBUTE(window1,2,'TRAT_Disabled',0)
  200. CALL TR_SETATTRIBUTE(window1,3,'TRAT_Disabled',0)
  201. end
  202. if what=3 then;do
  203. void=SetClip("Cod3",such)
  204. Cod4=GetClip("Cod4")
  205. CALL TR_SETATTRIBUTE(window1,21,'TROB_String',Cod4)
  206. end
  207. End
  208. WHEN event.trm_id=22 THEN;do
  209. what=event.trm_data+1
  210. such=TR_GETATTRIBUTE(window1,24,'TROB_String')
  211. if what=1 then;do
  212. void=SetClip("Spez4",such)
  213. CALL TR_SETATTRIBUTE(window1,23,'TRAT_Disabled',1)
  214. CALL TR_SETATTRIBUTE(window1,24,'TROB_String','')
  215. CALL TR_SETATTRIBUTE(window1,24,'TRAT_Disabled',1)
  216. end
  217. if what=2 then;do
  218. Spez3=GetClip("Spez3")
  219. CALL TR_SETATTRIBUTE(window1,23,'TRAT_Disabled',0)
  220. CALL TR_SETATTRIBUTE(window1,24,'TROB_String',Spez3)
  221. CALL TR_SETATTRIBUTE(window1,24,'TRAT_Disabled',0)
  222. end
  223. if what=3 then;do
  224. void=SetClip("Spez3",such)
  225. Spez4=GetClip("Spez4")
  226. CALL TR_SETATTRIBUTE(window1,24,'TROB_String',Spez4)
  227. end
  228. End
  229. OTHERWISE NOP
  230. END
  231. END
  232. IF event.trm_class='TRMS_CLOSEWINDOW' THEN ende=1
  233. IF event.trm_class='TRMS_ACTION' THEN;DO
  234. SELECT
  235. WHEN event.trm_id=13 THEN;Do
  236. what=TR_GETATTRIBUTE(window1,12,'TRAT_VALUE')
  237. if what=1 then;do
  238. STATUS NumFonts
  239. Font.0=result
  240. Do i=1 to Font.0
  241. Status FontName i
  242. Font.i=result
  243. End
  244. If Font.0=1 then FontAusw=Font.1
  245. Else Call fontlist
  246. End
  247. if what=2 then;do
  248. Font.0=4
  249. Font.1='Normal'
  250. Font.2='Unterstrichen'
  251. Font.3='Doppelt Unterstrichen'
  252. Font.4='Durchgestrichen'
  253. Call fontlist
  254. End
  255. if fontausw~='' then CALL TR_SETATTRIBUTE(window1,14,'TROB_String',FontAusw)
  256. END
  257. WHEN event.trm_id=23 THEN;Do
  258. what=TR_GETATTRIBUTE(window1,22,'TRAT_VALUE')
  259. if what=1 then;do
  260. nee="FWFonts/SWOLFonts"
  261. dir=rtfilerequest(nee,,"Font auswählen...",,"rt_pubscrname = FinalWriterPubScreen")
  262. End
  263. if what=2 then;do
  264. Font.0=4
  265. Font.1='Normal'
  266. Font.2='Unterstrichen'
  267. Font.3='Doppelt Unterstrichen'
  268. Font.4='Durchgestrichen'
  269. Call fontlist
  270. dir=fontausw
  271. End
  272. if dir~='' then CALL TR_SETATTRIBUTE(window1,24,'TROB_String',dir)
  273. END
  274. WHEN event.trm_id=1 THEN;Do
  275. All=false;Suchen=true
  276. Call program
  277. END
  278. WHEN event.trm_id=2 THEN;Do
  279. All=false;Suchen=false
  280. Call program
  281. END
  282. WHEN event.trm_id=3 THEN;Do
  283. All=true;Suchen=false
  284. Call program
  285. END
  286. WHEN event.trm_id=101 THEN Call rtezrequest("Aus dem Makro-Paket:"||R||R||"Suchen & Ersetzen V2.1 für FW"||R||"© 1998 Heiko Schröder","Danke für Ihre Registrierung.","Info","rt_pubscrname=FinalWriterPubScreen")
  287. WHEN event.trm_id=103 THEN address command "run Multiview PUBSCREEN=FinalWriterPubScreen "||d2c(34)||HilfeVerz||"Suchen&Ersetzen.guide"||d2c(34)
  288. WHEN event.trm_id=104 THEN ende=1
  289. OTHERWISE NOP
  290. END
  291. END
  292. END
  293. END
  294. CALL TR_CLOSEPROJECT(window1)
  295. END
  296. CALL TR_DELETEAPP(app)
  297. END
  298. ELSE
  299. CALL quit('Kann das Fenster nicht öffnen',10)
  300. Exit
  301. program:
  302. code1=TR_GETATTRIBUTE(window1,10,'TRAT_VALUE')
  303. art1=TR_GETATTRIBUTE(window1,12,'TRAT_VALUE')
  304. code2=TR_GETATTRIBUTE(window1,20,'TRAT_VALUE')
  305. art2=TR_GETATTRIBUTE(window1,22,'TRAT_VALUE')
  306. such=TR_GETATTRIBUTE(window1,11,'TROB_String')
  307. suchfont=TR_GETATTRIBUTE(window1,14,'TROB_String')
  308. erse=TR_GETATTRIBUTE(window1,21,'TROB_String')
  309. ersefont=TR_GETATTRIBUTE(window1,24,'TROB_String')
  310. Cursor Left;Cursor Right
  311. if such="" then;do
  312. x=rtezrequest("Bitte Suchwort eingeben","_Achso","FEHLER","rt_pubscrname=FinalWriterPubScreen")
  313. return
  314. end
  315. if art1=2 then;do
  316. Select
  317. When suchfont='Unterstrichen' then suchfont='UnderLine'
  318. When suchfont='Doppelt Unterstrichen' then suchfont='DUnderLine'
  319. When suchfont='Durchgestrichen' then suchfont='StrikeThru'
  320. Otherwise suchfont='Normal'
  321. end
  322. end
  323. if art2=2 then;do
  324. Select
  325. When ersefont='Unterstrichen' then ersefont='UnderLine'
  326. When ersefont='Doppelt Unterstrichen' then ersefont='DUnderLine'
  327. When ersefont='Durchgestrichen' then ersefont='StrikeThru'
  328. Otherwise ersefont='Normal'
  329. end
  330. end
  331. If code1=1 then;do
  332. If (such<0|such>255) then;do
  333. x=rtezrequest("Der Such-Code muß zwischen 1...255 liegen","_Achso","FEHLER","rt_pubscrname=FinalWriterPubScreen")
  334. return
  335. End
  336. If Datatype(such,'N')=1 then such=d2c(such)
  337. Else;do
  338. x=rtezrequest("Bitte den Such-Code eingeben","_Achso","FEHLER","rt_pubscrname=FinalWriterPubScreen")
  339. return
  340. End
  341. End
  342. If code2=2 then;do
  343. If (erse<0|erse>255) then;do
  344. x=rtezrequest("Der Ersetzen-Code muß zwischen 1...255 liegen","_Achso","FEHLER","rt_pubscrname=FinalWriterPubScreen")
  345. return
  346. End
  347. If (erse~=''& Datatype(erse,'N')=1) then erse=d2c(erse)
  348. Else erse=''
  349. End
  350. If All=true then REDRAWOFF
  351. If art1=1 then;do
  352. If suchfont~='' then;do
  353. Call schrift suchfont;suchfont=FontArt
  354. if a~=0 then;do
  355. x=rtezrequest("Der Such-Font ist kein FW typischer Font...","_Achso","FEHLER","rt_pubscrname=FinalWriterPubScreen")
  356. return
  357. end
  358. end
  359. End
  360. If art2=1 then;do
  361. If ersefont~='' then;do
  362. Call schrift ersefont;ersefont=FontArt
  363. if a~=0 then;do
  364. x=rtezrequest("Der Ersetzen-Font ist kein FW typischer Font...","_Achso","FEHLER","rt_pubscrname=FinalWriterPubScreen")
  365. return
  366. end
  367. end
  368. end
  369. address(FW)
  370. Menge=0
  371. SETFIND CASE Same WRAP No
  372. FIND
  373. if art1~=0 then x=rtezrequest("Optionen im FW-Suchen Requester einstellen.","_Getan","ACHTUNG!","rt_pubscrname=FinalWriterPubScreen")
  374. rpl=false
  375. fnd=false
  376. DO until ok~=0
  377. rpl=false
  378. FIND such
  379. ok=RC
  380. if ok=0 then;do
  381. Select
  382. When (suchfont=''&ersefont='') then;do
  383. Type erse
  384. rpl=true
  385. End
  386. When (suchfont=''&ersefont~='') then;do
  387. if art2=1 then;do
  388. Type erse;ShiftDown
  389. do p=1 to Length(erse)
  390. Cursor LEFT
  391. End
  392. End
  393. If art2=1 then Font ersefont
  394. If art2=2 then Style ersefont
  395. rpl=true
  396. End
  397. When (suchfont~=''&ersefont='') then;do
  398. if art1=1 then;do
  399. STATUS FontName
  400. suchfound=result
  401. end
  402. if art1=2 then;do
  403. STATUS FontStyle
  404. suchfound=result
  405. end
  406. if upper(suchfont)=upper(suchfound) then;do
  407. If Suchen=false then;do
  408. Type erse
  409. rpl=true
  410. end
  411. else;do
  412. fnd=true
  413. end
  414. End
  415. End
  416. When (suchfont~=''&ersefont~='') then;do
  417. if art1=1 then;do
  418. STATUS FontName
  419. suchfound=result
  420. end
  421. if art1=2 then;do
  422. STATUS FontStyle
  423. suchfound=result
  424. end
  425. if upper(suchfont)=upper(suchfound) then;do
  426. If Suchen=false then;do
  427. Type erse;ShiftDown
  428. do p=1 to Length(erse)
  429. Cursor LEFT
  430. End
  431. If art2=1 then Font ersefont
  432. If art2=2 then Style ersefont
  433. rpl=true
  434. end
  435. else;do
  436. fnd=true
  437. end
  438. End
  439. End
  440. Otherwise NOP
  441. End
  442. if rpl=true then Menge=Menge+1
  443. End
  444. If (erse=''&Suchen=false) then Delete
  445. If (All=false&rpl=true) then leave
  446. If (All=false&fnd=true) then leave
  447. END
  448. If All=true then;do
  449. REDRAWON
  450. REDRAW
  451. if menge=1 then text="Es wurde "Menge" Ersetzung vorgenommen."
  452. else text="Es wurden "Menge" Ersetzungen vorgenommen."
  453. if menge=0 then text="Der Suchbegriff wurde nicht gefunden."
  454. x=rtezrequest(text||R||"Bitte FW-Suchen-Requester schließen.","_Okay","FERTIG!","rt_pubscrname=FinalWriterPubScreen")
  455. end
  456. Return
  457. schrift:
  458. Cursor Right
  459. Cursor Left
  460. Parse Arg FontArt
  461. Font FontArt
  462. a=RC
  463. If a~=0 then return
  464. Type d2c(32)
  465. STATUS FontPath
  466. FullFontName=result
  467. pos=max(index(FullFontName,':'),lastpos('/',FullFontName))
  468. IF (pos~=0) THEN;do
  469. FontArt=RIGHT(FullFontName,LENGTH(FullFontName)-pos)
  470. END
  471. BackSpace
  472. return
  473. fontlist:
  474. window2=TR_OPENPROJECT(app,WindowID(2),
  475. WindowPosition('TRWP_CENTERDISPLAY'),
  476. PubScreenName(FWP),
  477. WindowTitle("Bitte wählen Sie:"),
  478. 'VertGroupAC',
  479. FWListSelC('Font',1,0) 'TRAT_Flags TRLV_ShowSelected',
  480. 'EndGroup',
  481. 'EndProject')
  482. IF window2 ~='00000000'x THEN;DO
  483. ande=0
  484. DO WHILE ~ande
  485. CALL TR_WAIT(app,'')
  486. DO WHILE TR_HANDLEMSG(app,'event')
  487. IF event.trm_class='TRMS_CLOSEWINDOW' THEN;DO
  488. FontAusw=''
  489. ande=1
  490. End
  491. IF event.trm_class='TRMS_NEWVALUE' THEN;DO
  492. SELECT
  493. WHEN event.trm_id=1 THEN;do
  494. Anz=TR_GETATTRIBUTE(window2,1,'TRAT_VALUE')+1
  495. FontAusw=Font.Anz
  496. ande=1
  497. End
  498. OTHERWISE
  499. NOP
  500. END
  501. END
  502. END
  503. END
  504. CALL TR_CLOSEPROJECT(window2)
  505. END
  506. ELSE
  507. CALL quit('Kann das Fenster nicht öffnen',10)
  508. Return
  509. syntax:
  510. CALL quit('Fehler' rc 'in Zeile' sigl '-' ERRORTEXT(rc)||R||SOURCELINE(sigl)||R||'Bitte informieren Sie den Autor...',20)
  511. quit:
  512. PARSE ARG message,rcode
  513. IF app ~='00000000'x THEN;DO
  514. IF message ~='' THEN
  515. x=rtezrequest(message,"_Okay","ACHTUNG!","rt_pubscrname=FinalWriterPubScreen")
  516. CALL TR_DELETEAPP(app)
  517. END
  518. ELSE;DO
  519. IF message ~='' THEN;DO
  520. SAY message
  521. SAY
  522. OPTIONS PROMPT 'Bitte <RETURN> drücken'
  523. PULL taste
  524. END
  525. END
  526. address command "flushtrx all"
  527. EXIT(rcode)